<?php

            $order = [];
		
			$order['out_trade_no'] = '2025041200';
			$order['jump_url'] = 'http://127.0.0.1';
            $client_id = 70;
            $name = "测试支付";
			$money = 1000;
		
			$apiurl = 'https://www.0123btc.com/otctrade/bargain';
			$data = array(
				'name' => $name,
				'price' => (int)$money,
				'client_order_id' => $order['out_trade_no'],//订单号
				// 'client_order_uid' => $_G['uid'],
				'notify_url' => 	$order['jump_url'],
				'client_id' => $client_id, /* 手动填写client_id */
				// 'key' => $pay_list['zfb_key']  /* 后台配置,也可以直接在这里写 */
			);
			
			ksort($data);
       
			$DataKey = http_build_query($data);
			$DataKey = urldecode($DataKey);
			$DataKey = strtolower($DataKey);
			$DataKey = str_replace(' ', '', $DataKey);
			
			function getByteUtf8($data){
				$bytes = unpack("c*", $data);
				$str = '';
				foreach ($bytes as $ch) {
					$str .= chr($ch);
				}
				return $str;
			}

			$DataKey = getByteUtf8($DataKey);

			$DataKey = sha1($DataKey);

			$data['sign'] = $DataKey;

			$data = array_diff_key($data, ['key' => '']);
			var_dump($data);
			$curl = curl_init();

			curl_setopt_array($curl, array(
				CURLOPT_URL => "https://www.0123btc.com/otctrade/bargain",
				CURLOPT_RETURNTRANSFER => true,
				CURLOPT_ENCODING => "",
				CURLOPT_MAXREDIRS => 10,
				CURLOPT_TIMEOUT => 30,
                 CURLOPT_SSL_VERIFYPEER => 0, // 关闭 SSL 验证
                CURLOPT_SSL_VERIFYHOST => 0, // 关闭 SSL 验证;
				CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
				CURLOPT_CUSTOMREQUEST => "POST",
				CURLOPT_POSTFIELDS => json_encode($data),
				CURLOPT_HTTPHEADER => array(
					"Content-Type:application/json"
				),
			));

			$response = curl_exec($curl);

			$err = curl_error($curl);
          
			curl_close($curl);
           
			if ($err) {
				$arr['error'] = '"out_trade_no" or "buy_creation" no value';
				arrjson_iconv($arr);
			} else {
			
				$jg = json_decode($response);
                print_r($jg );exit;
				if ($jg->status == 0) {
					$arr['url'] = $jg->data->visit_url;
					if (empty($arr['url'])) {
						$arr['error'] = '"out_trade_no" or "buy_creation" no value';
						arrjson_iconv($arr);
					}
					$arr['wxsm'] = $order['pay_pyte'];
					$arr['out_trade_no'] = $order['out_trade_no'];
					$arr['nurl'] = $order['jump_url'];
					arrjson_iconv($arr);
				} else {
					$arr['error'] = $jg->reason;
					if (empty($arr['error'])) {
						$arr['error'] = '支付平台未返回报错原因，错误代码：' . $jg->status;
					}
					arrjson_iconv($arr);
				}
			}